/*
 * @Author: szx
 * @Date: 2022-02-25 13:54:28
 * @LastEditTime: 2022-02-25 14:03:50
 * @Description:
 * @FilePath: \leetcode\剑指offer\47\47.js
 */
/**
 * @param {number[][]} grid
 * @return {number}
 */
var maxValue = function (grid) {
    const m = grid.length;
    const n = grid[0].length;
    const dp = new Array(n + 1).fill(0);
    for (let i = 1; i <= m; i++) {
        for (let j = 1; j <= n; j++) {
            dp[j] = Math.max(dp[j], dp[j - 1]) + grid[i - 1][j - 1];
        }
    }
    return dp[n];
};
